package org.musicmod.android.utils;

import org.musicmod.android.Constants;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class SharedPrefsUtils implements Constants {
	public static short getEqualizerSetting(Context context, short band,
			short def) {
		SharedPreferences prefs = context.getSharedPreferences(
				SHAREDPREFS_EQUALIZER, Context.MODE_PRIVATE);
		return Short.valueOf(prefs.getString(String.valueOf(band),
				String.valueOf(def)));
	}

	public static void setEqualizerSetting(Context context, short band,
			short value) {
		SharedPreferences prefs = context.getSharedPreferences(
				SHAREDPREFS_EQUALIZER, Context.MODE_PRIVATE);
		Editor ed = prefs.edit();
		ed.putString(String.valueOf(band), String.valueOf(value));
		ed.commit();
	}

	public static int getIntState(Context context, String name, int def) {
		SharedPreferences prefs = context.getSharedPreferences(
				SHAREDPREFS_STATES, Context.MODE_PRIVATE);
		return prefs.getInt(name, def);
	}

	public static void setIntState(Context context, String name, int value) {
		SharedPreferences prefs = context.getSharedPreferences(
				SHAREDPREFS_STATES, Context.MODE_PRIVATE);
		Editor ed = prefs.edit();
		ed.putInt(name, value);
		ed.commit();
	}

	public static long getLongState(Context context, String name, long def) {
		SharedPreferences prefs = context.getSharedPreferences(
				SHAREDPREFS_STATES, Context.MODE_PRIVATE);
		return prefs.getLong(name, def);
	}

	public static void setLongState(Context context, String name, long value) {
		SharedPreferences prefs = context.getSharedPreferences(
				SHAREDPREFS_STATES, Context.MODE_PRIVATE);
		Editor ed = prefs.edit();
		ed.putLong(name, value);
		ed.commit();
	}

	public static boolean getBooleanState(Context context, String name,
			boolean def) {
		SharedPreferences prefs = context.getSharedPreferences(
				SHAREDPREFS_STATES, Context.MODE_PRIVATE);
		return prefs.getBoolean(name, def);
	}

	public static void setBooleanState(Context context, String name,
			boolean value) {
		SharedPreferences preferences = context.getSharedPreferences(
				SHAREDPREFS_STATES, Context.MODE_PRIVATE);
		Editor editor = preferences.edit();
		editor.putBoolean(name, value);
		editor.commit();
	}

	public static String getStringState(Context context, String name, String def) {
		SharedPreferences prefs = context.getSharedPreferences(
				SHAREDPREFS_STATES, Context.MODE_PRIVATE);
		return prefs.getString(name, def);
	}

	public static void setStringState(Context context, String name, String value) {
		SharedPreferences preferences = context.getSharedPreferences(
				SHAREDPREFS_STATES, Context.MODE_PRIVATE);
		Editor editor = preferences.edit();
		editor.putString(name, value);
		editor.commit();
	}

	public static int getIntPreference(Context context, String name, int def) {
		SharedPreferences prefs = context.getSharedPreferences(
				SHAREDPREFS_PREFERENCES, Context.MODE_PRIVATE);
		return prefs.getInt(name, def);
	}

	public static void setIntPreference(Context context, String name, int value) {
		SharedPreferences prefs = context.getSharedPreferences(
				SHAREDPREFS_PREFERENCES, Context.MODE_PRIVATE);
		Editor ed = prefs.edit();
		ed.putInt(name, value);
		ed.commit();
	}

	public static float getFloatPreference(Context context, String name,
			float def) {
		SharedPreferences prefs = context.getSharedPreferences(
				SHAREDPREFS_PREFERENCES, Context.MODE_PRIVATE);
		return prefs.getFloat(name, def);
	}

	public static void setFloatPreference(Context context, String name,
			float value) {
		SharedPreferences prefs = context.getSharedPreferences(
				SHAREDPREFS_PREFERENCES, Context.MODE_PRIVATE);
		Editor ed = prefs.edit();
		ed.putFloat(name, value);
		ed.commit();
	}

	public static boolean getBooleanPreference(Context context, String name,
			boolean def) {
		SharedPreferences prefs = context.getSharedPreferences(
				SHAREDPREFS_PREFERENCES, Context.MODE_PRIVATE);
		return prefs.getBoolean(name, def);
	}

	public static void setBooleanPreference(Context context, String name,
			boolean value) {
		SharedPreferences preferences = context.getSharedPreferences(
				SHAREDPREFS_PREFERENCES, Context.MODE_PRIVATE);
		Editor editor = preferences.edit();
		editor.putBoolean(name, value);
		editor.commit();
	}

	public static String getStringPreference(Context context, String name,
			String def) {
		SharedPreferences prefs = context.getSharedPreferences(
				SHAREDPREFS_PREFERENCES, Context.MODE_PRIVATE);
		return prefs.getString(name, def);
	}

	public static void setStringPreference(Context context, String name,
			String value) {
		SharedPreferences preferences = context.getSharedPreferences(
				SHAREDPREFS_PREFERENCES, Context.MODE_PRIVATE);
		Editor editor = preferences.edit();
		editor.putString(name, value);
		editor.commit();
	}
}